<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3" xmlns:head="http://www.w3.org/1999/html">
<head th:include="public/public_css::public_css ('解冻库存')"/>

<body style="background-color: #f2f2f2;">
<div class="layui-fluid larry-wrapper">
    <input type="hidden" th:value="${id}" id="kid">
    <div class="layui-card">
        <div class="layui-row layui-col-space30">
            <div class="layui-col-xs24">
                <!--<div class="group-button" id="toolbar">
                    <a class="layui-btn layui-btn-sm layui-btn-normal add-btn">
                        <i class="layui-icon">&#x1005;</i> 解冻
                    </a>
                </div>-->
                <!--列表-->
                <section class="panel panel-padding layui-card-body">
                    <div class="pro">
                        <table id="table"></table>
                    </div>
                </section>
                <!--<div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" jq-filter="submit" lay-submit="" lay-filter="editKq">立即提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>-->
            </div>
        </div>
    </div>
</div>
</body>
<div th:include="/public/public_js::public_js"></div>
<style type="text/css">
    .gw_num{border: 1px solid #dbdbdb;width: 110px;line-height: 26px;overflow: hidden;}
    .gw_num em{display: block;height: 26px;width: 26px;float: left;color: #7A7979;border-right: 1px solid #dbdbdb;text-align: center;cursor: pointer;}
    .gw_num .num{display: block;float: left;text-align: center;width: 52px;font-style: normal;font-size: 14px;line-height: 24px;border: 0;}
    .gw_num em.add{float: right;border-right: 0;border-left: 1px solid #dbdbdb;}
</style>
<script>

/*    $(document).ready(function(){
//加的效果
        $(".add").click(function(){
            var n=$(this).prev().val();
            var num=parseInt(n)+1;
            if(num==0){ return;}
            $(this).prev().val(num);
        });
//减的效果
        $(".jian").click(function(){
            var n=$(this).next().val();
            var num=parseInt(n)-1;
            if(num==0){ return}
            $(this).next().val(num);
        });
    })*/

    layui.use(['list', 'layer', 'zzpUtils', 'jquery', 'laydate'], function () {
        window.operateEvent = {

            "click #btn_jd": function (e, value, row, index) {//解冻
                var jiedongnumber = $('#dongjieNumber').val();
                if (parseInt(jiedongnumber) <= parseInt(row.djsl)) {
                    console.log('dongjieNumber', jiedongnumber);
                     btn_jd(row.id,jiedongnumber);
                } else {
                    $('#dongjieNumber').val(row.djsl);
                }

            }
        }

        var zzpUtils = layui.zzpUtils,
            $ = layui.jquery,
            laydate = layui.laydate;

        //解冻
        function btn_jd(ids,kdjsl) {
            //获取主页id
            var id=ids;
            var arr  =
                {
                    id,
                    kdjsl
                }
            var list_map = new Array();
            list_map.push(arr)
            id=$("#kid").val();
            zzpUtils.action({
                url:"/wmsstockfrozen/stockThaw",
                data: JSON.stringify({list: list_map, id}),
                success:function (data) {
                    zzpUtils.loadJsonDataToForm(data);
                },error: function (xhr, textStatus) {
                    console.log(textStatus);
                    console.log(xhr)
                },
                end: function () {//修改成功后刷新
                    zzpUtils.refreshTable("#table");
                }
            });
        }
        var $table = zzpUtils.table({
            elem: '#table',
            isApi: true,
            pagination: true,
            url: '/wmsstockfrozen/searchFrozenMx?ssyqdid='+$("#kid").val(),
            columns: [{
                field: '',
                checkbox: true
            }, {
                field: 'hpbh',
                title: '货品编号'
            }, {
                field: 'hpmc',
                title: '货品名称'
            }, {
                field: 'hppc',
                title: '货品批次'
            }, {
                field: 'scrq',
                title: '生产日期'
            }, {
                field: 'zxl',
                title: '装箱量'
            }, {
                field: 'dwms',
                title: '单位描述'
            }, {
                field: 'djsl',
                title: '可解冻数量',
                formatter: operateFormatterNumber,
            },{
                field: 'kwmc',
                title: '库位名称'
            },{
                field: 'djsl',
                title: '可冻结数量'
            }, {
                field: 'caozuo',
                title: '操作',
                events: operateEvent,
                formatter: operateFormatter
            }]
        });
        /*表格右侧按钮*/
        function operateFormatter(value, row, index) {
            return [
                '<a class="layui-btn layui-btn-xs" id="btn_jd">解冻</a>'
            ].join('')
        }

        function operateFormatterNumber (value) {
            return [
                '<input type="text" id="dongjieNumber" value="'+ value +'"/>',
            ].join('')
        }

        /*顶部按钮多选解冻*/
        /*$(".add-btn").on('click', function () {
            var $rows = $table.bootstrapTable('getSelections');
            if ($rows.length == 1) {
                /!*var ids = $.map($rows, function (row) {
                    return row.id;
                })*!/
                var id=$("#kid").val();
                zzpUtils.action({
                    url:"/wmsstockfrozen/stockThaw",
                    data: JSON.stringify({list: list_map, id}),
                    success:function (data) {
                        zzpUtils.loadJsonDataToForm(data);
                    },error: function (xhr, textStatus) {
                        console.log(textStatus);
                        console.log(xhr)
                    }
                });
            } else {
                layer.msg("请选择一条进行解冻");
            }
        })*/

        /*顶部按钮多选启用*/
        /*$("#btn_qi").on('click', function () {
            var index = 0;
            var $rows = $table.bootstrapTable('getSelections');
            //判断选中的库区里是否有已经启用的
            for (var i = 0; i < $rows.length; i++) {
                if ($rows[i].jhzt == 1) {
                    index++;
                }
            }
        })*/
    });

</script>
</html>